#ifndef SOS_H_
#define SOS_H_
#include <8051.h>
/* This is used to manipulate SFRs ex. SP */
#define DEREF(NAME) *((data unsigned char* )NAME)
#define gl_start_of_stack 0x30

typedef void (*t_task_fn)(void);
/**
 * TCB
 */
typedef struct 
 {
 	unsigned char id;
 	/* external stack pointer */
 	unsigned char* pxstack;
 	/* start of stack. Used to keep track of stack size*/
	const unsigned int* pxstack_start;
 	/* task state */
 	enum TaskState task_state;
	/* if suspended on a semaphore */
	unsigned char* sem_address;
	/* */
	t_task_fn task_fn_ptr;
 }TCB;
 /****************************************************************************/
/***************************TASK MANAGEMENT**********************************/
/****************************************************************************/

enum TaskState { TS_RUNNING=0x01, TS_READY=0x02, TS_WAITING=0x04, TS_SUSPEND=0x08, TS_ISR=0x16 }; 


 //task function pointer
void (*pfn_task) (void) ;


//Semaphore support
typedef xdata unsigned char* semaphore;


#endif /*SOS_H_*/
